
<?
	   layout("/inc/win_layout.html",{title:sysTitle}){
    ?>

<div class="row">
		<div class="col-lg-12">
				<div class="panel" >
					<div class="panel-body pan " style="width:auto;height:525px;overflow: auto;">
						<form action="#" class="form-horizontal">
							<div class="form-body pal"
								style="float:left;width:100%; overflow: auto;">
								<input id="id" type="hidden" class="form-control" />

								<div style="margin-top:-10px;  padding-bottom: 5px;">
									<label for="wordName" class="col-md-4 control-label">
										<div align="right">
											主题款目词<span class='require' >*</span>
										</div> </label>
									<div class="col-md-8">
										<div class="input-icon">
											<input id="wordName" type="text" class="form-control" />
										</div>
									</div>
								</div>
								
								<div style="padding-bottom: 5px;">
									<label for="wordFormal" class="col-md-3 control-label">词表分类
										<span class='require'>*</span> </label>
									<div class="col-md-9">
										<div class="input-icon">
											<select id="wordClasses" class="form-control">
												<?for(twm in thesauriWordModule){?>
													<option value="${twm.id}">${twm.nameZh}</option>
												<?}?>
											</select>
										</div>
									</div>
								</div>
								
								<div id="topTermXia" style="padding-bottom: 5px;">
									<label for="isTopTerm" class="col-md-3 control-label">是否族首词
										<span class='require'>*</span> </label>
									<div class="col-md-9">
										<div class="input-icon">
											<select id="isTopTerm" class="form-control">
												<option value="0">false</option>
												<option value="1">true</option>
											</select>
										</div>
									</div>
								</div>
								<div style="padding-bottom: 5px;">
									<label for="wordFormal" class="col-md-3 control-label">是否正式主题词
										<span class='require'>*</span> </label>
									<div class="col-md-9">
										<div class="input-icon">
											<select id="wordFormal" class="form-control">
												<option value="0">true</option>
												<option value="1">false</option>
											</select>
										</div>
									</div>
								</div>

								<div style="padding-bottom: 5px;">
									<label for="wordPinyin" class="col-md-4 control-label">
										<div align="right">
											汉语拼音 
										</div> </label>
									<div class="col-md-8">
										<div class="input-icon">
											<input id="wordPinyin" type="text" class="form-control" onchange="verify(this.value,this.id);" />
										</div>
									</div>
								</div>

								<div style="padding-bottom: 5px;">
									<label for="wordEnglish" class="col-md-4 control-label">
										<div align="right">
											英文译名 
										</div> </label>
									<div class="col-md-8">
										<div class="input-icon">
											<input id="wordEnglish" type="text" class="form-control" onchange="verify(this.value,this.id);" />
										</div>
									</div>
								</div>
								
								
								<div style="padding-bottom: 5px;">
										<label for="thesauriWordCategoryName" class="col-md-3 control-label">
											<div align="right">范畴名称<span class='require' >*</span></div>
											</label>
										<div class="col-md-9">
											<div class="input-group input-group-sm mbs">
												<input id="thesauriWordCategoryName" type="text" placeholder="请选择"
													class="form-control" disabled="true" /> <span
													class="input-group-btn"><button id="xuanze"
														onclick="saveEditZTree()" type="button"
														data-toggle="dropdown"
														class="btn btn-success dropdown-toggle">选择类..</button>
												</span>
											</div>
										</div>
								</div>
								<input id="thesauriWordCategoryId" type="hidden" class="form-control" />
								
								<div style="padding-bottom: 5px;">
									<label for="scopeNote" class="col-md-4 control-label">
										<div align="right">
											含义注释 <span class='require' ></span>
										</div> </label>
									<div class="col-md-8">
										<div class="input-icon">
											<textarea id="scopeNote"  rows="3" cols="20" class="form-control" ></textarea> 
										</div>
									</div>
								</div>
								
								<div style="padding-bottom: 5px;">
									<label for="usageNote" class="col-md-4 control-label">
										<div align="right">
											用法注释 <span class='require'></span>
										</div> </label>
									<div class="col-md-8">
										<div class="input-icon">
											<textarea id="usageNote"  rows="3" cols="20" class="form-control" ></textarea> 
										</div>
									</div>
								</div>
								
								<div style="padding-bottom: 0px;">
									<label for="historicalNote" class="col-md-4 control-label">
										<div align="right">
										     历史注释 <span class='require'></span>
										</div> </label>
									<div class="col-md-8">
										<div class="input-icon">
											<textarea id="historicalNote"  rows="3" cols="20" class="form-control" ></textarea> 
										</div>
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
		</div>
</div>

<?} ?>
<script>
	function getQueryString(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); return null; 
	} 
	var winName=getQueryString("winName");
	var counts=getQueryString("source");
	var addwordClasses=getQueryString("addwordClasses");
	var cengjiguanxi=""; 
	if(winName==""){
		 cengjiguanxi=window.parent;
	}else{
		cengjiguanxi=window.parent.window[winName];
	}
	var shanchu=cengjiguanxi.getShanChu();
	var source=cengjiguanxi.getsource();
	var twrId=cengjiguanxi.getTwrId();
	var thesauriWordId = cengjiguanxi.getThesauriWordId();
	$("#id").val(thesauriWordId);
	$(function() {
		if (thesauriWordId != 0) {
			demo1();
		}
		selected("wordClasses", addwordClasses);
	});
	function Page() {

				if($.trim($("#wordName").val()).length<1) {
		        	alert('词名称不能为空！');
		        	return null;
		        }
		        if($.trim($("#isTopTerm").val())==-1) {
		        	alert('请选择是或否！');
		        	return null;
		        }
		       /*  if($.trim($("#wordPinyin").val()).length<1) {
		        	alert('汉语拼音不能为空！');
		        	return null;
		        }
		        if($.trim($("#wordEnglish").val()).length<1){
		        	alert('英文译名不能为空！');
		        	return null;
		        } */
		        if($.trim($("#thesauriWordCategoryId").val()).length<1) {
		        	alert('请选择范畴！');
		        	return null;
		        }
		       
		$.ajax({
			type : "post",
			url : "./thesauriWordAddEdit.do",
			data : {
				"id" : thesauriWordId,
				"wordName" : $("#wordName").val(),
				"isTopTerm" : $("#isTopTerm").val(),
				"wordPinyin" : $("#wordPinyin").val(),
				"wordEnglish": $("#wordEnglish").val(),
				"thesauriWordCategoryId" : $("#thesauriWordCategoryId").val(),
				"scopeNote" : $("#scopeNote").val(),
				"usageNote" : $("#usageNote").val(),
				"historicalNote" : $("#historicalNote").val(),
				"wordFormal" : $("#wordFormal").val(),
				"wordClasses" : $("#wordClasses").val(),
			},
			dataType : "json",
			async : true,
			success : function(data) {
				if(shanchu==1){
					var index = parent.layer.getFrameIndex(window.name);
					cengjiguanxi.findEditThesauriWordReference();
					cengjiguanxi.layer.msg('提交成功');
					parent.layer.close(index);
				}else if(shanchu==6){
					var index = parent.layer.getFrameIndex(window.name);
					cengjiguanxi.layer.msg('提交成功');
					parent.layer.close(index);
				}else{
					var index = parent.layer.getFrameIndex(window.name);
					cengjiguanxi.tuxinghua(addwordClasses);
					cengjiguanxi.findAllthesauriWordReferenceLieBiao(counts);
					cengjiguanxi.layer.msg('提交成功');
					parent.layer.close(index);
				}
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	}
	
	function demo1() {
		$.getJSON('./thesauriWordEditShow.do', {
			id : thesauriWordId,
		//向服务端传的参数，此处只是演示
		}, function(res) {
			//此处仅仅是为了演示变化的内容
			$("#wordName").val(res[0].wordName);
			$("#isTopTerm").val(res[0].isTopTerm);
			selected("wordClasses",res[0].thesauriWordModuleId);
			$("#wordPinyin").val(res[0].wordPinyin);
			$("#wordEnglish").val(res[0].wordEnglish);
			$("#thesauriWordCategoryName").val(res[0].thesauriWordCategoryName);
			$("#thesauriWordCategoryId").val(res[0].thesauriWordCategoryId);
			$("#scopeNote").val(res[0].scopeNote);
			$("#usageNote").val(res[0].usageNote);
			$("#historicalNote").val(res[0].historicalNote);
			$("#wordFormal").val(res[0].wordFormal);
			addwordClasses=res[0].thesauriWordModuleId;
		});
	};
	
	function selected(selectname, selectid) {
		$("#" + selectname + " option").each(function() { //遍历全部option
			var v = $(this).val(); //获取option的内容
			if (v == selectid) {
				$(this).attr("selected", "selected");
			}
		});
	}
	
	
	var gongYongZiDuan;
	function getGongYongZiDuan(){
		return gongYongZiDuan;
	}
	var inputPId;
	function getInputPId(){
		return inputPId;
	}
	var inputPName;
	function getInputPName(){
		return inputPName;
	}
	var thesauriWordCategoryId;
	function getThesauriWordCategoryId(){
		return thesauriWordCategoryId;
	}
	function getclassesIds(){
		return addwordClasses;
	}
	//验证
	function verify(verifyName,verifyId){
		var regu="[\u4e00-\u9fa5]";
		var re = new RegExp(regu);
		if (re.test(verifyName)) {
	        alert("输入不符合规则，请重新输入！");
	        $("#"+verifyId).val("");
   		 }
	}
	
	function saveEditZTree() {
		gongYongZiDuan="叙词表(主题款目词表)";
		thesauriWordCategoryId =$("#thesauriWordCategoryId").val();
		inputPId="thesauriWordCategoryId";
		inputPName="thesauriWordCategoryName";
		parent.layer.open({
					type : 2,
					area : [ '650px', '600px' ],
					fix : false, //不固定
					//maxmin : true,
					scrollbar : false,
					shadeClose : true,
					title : '选择父节点',
					btn : [ '保存 ', '关闭' ],
					skin : 'layui-layer-rim', //加上边框
					content : ["word-thesauriWordCategoryAddEditFind-zTree.html?winName="+window.name,'no'],
					yes : function(index, layer) {
						//var iframeWin = window.parent.window[window.name].window['layui-layer-iframe'+ index];
						var iframeWin = parent.window[layer.find('iframe')[0]['name']];
						//alert(iframeWin);
						iframeWin.queren();
					},
					cancel : function(index) {
					}
				});
	};

	function delThesauriWordReference() {
			if (confirm("是否确认删除！！")) {
				//alert("delThesauriWordReference");
				$.ajax({
					type : "post",
					url : "./delThesauriWordReference.do",
					data : {
						"id" : twrId,
						"thesauriWordId" : thesauriWordId,
						"source" :source
					},
					dataType : "json",
					async: true,
					cache: false,
					success : function(data) {
						if (data.count == 1) {
							if(shanchu==1){
								var index = parent.layer.getFrameIndex(window.name);
								cengjiguanxi.findEditThesauriWordReference();
								cengjiguanxi.layer.msg('删除成功');
								parent.layer.close(index);
							}else{
								var index = parent.layer.getFrameIndex(window.name);
								cengjiguanxi.tuxinghua(addwordClasses);
								cengjiguanxi.findAllthesauriWordReferenceLieBiao(counts);
								cengjiguanxi.layer.msg('删除成功');
								parent.layer.close(index);
							}
						}
					},
					error : function(data) {
						alert("请求失败");
					}
				});
			}
		}
		
	//汉字转拼音
  function pinYin(pinyinName){
		$.ajax({
			type : "post",
			url : "pinYin.do",
			data : {
				"pinYin" : pinyinName,
			},
			async : false,
			dataType : "json",
			success : function(data) {
				$("#wordPinyin").val(data);
				$("#wordEnglish").val(data);
				
			},
			error : function(data) {
				alert("请求失败");
			}
		})
	}	
		
		
</script>


